package com.stlm2.core;

import org.w3c.dom.Element;


public class WechatConfig {

    public static final String trade_type = "NATIVE";

    public static final String device_info = "WEB";

    public static final String encoding = "UTF-8";

    public static String appId;

    /**
     * app秘钥
     */
    public static String appSecret;

    /**
     * 商户号
     */
    public static String merchantId;

    /**
     * 商户秘钥
     */
    public static String merchantSecret;

    /**
     * 证书地址
     */
    public static String sslLocation;

    /**
     * 统一下单地址
     */
    public static String orderUrl;

    /**
     * 查询地址
     */
    public static String queryOrderUrl;

    /**
     * 退款地址
     */
    public static String refundOrderUrl;

    /**
     * 关闭订单地址d
     */
    public static String closeOrderUrl;

    /**
     * 支付成功回调地址
     */
    public static String payNotifyUrl;

    /**
     * 授权地址
     */
    public static String authorizeUrl;

    /**
     * 授权地址
     */
    public static String tokenUrl;

    /**
     * AccessToken地址
     */
    public static String accessTokenUrl;

    /**
     * JS API Token URL
     */
    public static String jsApiTicketUrl;


    /**
     * 初始化配置信息
     *
     * @param ele
     */
    public static void parse(Element ele) {
        if(ele == null){
            return ;
        }

        if(ele.hasAttribute("appId"))
            appId = ele.getAttribute("appId");

        if(ele.hasAttribute("merchantId"))
            merchantId = ele.getAttribute("merchantId");

        if(ele.hasAttribute("appSecret"))
            appSecret = ele.getAttribute("appSecret");

        if(ele.hasAttribute("merchantSecret"))
            merchantSecret = ele.getAttribute("merchantSecret");

        if(ele.hasAttribute("sslLocation"))
            sslLocation = ele.getAttribute("sslLocation");

        if(ele.hasAttribute("orderUrl"))
            orderUrl = ele.getAttribute("orderUrl");

        if(ele.hasAttribute("queryOrderUrl"))
            queryOrderUrl = ele.getAttribute("queryOrderUrl");

        if(ele.hasAttribute("closeOrderUrl"))
            closeOrderUrl = ele.getAttribute("closeOrderUrl");

        if(ele.hasAttribute("refundOrderUrl"))
            refundOrderUrl = ele.getAttribute("refundOrderUrl");

        if(ele.hasAttribute("payNotifyUrl"))
            payNotifyUrl = ele.getAttribute("payNotifyUrl");

        if(ele.hasAttribute("authorizeUrl"))
            authorizeUrl = ele.getAttribute("authorizeUrl");

        if(ele.hasAttribute("tokenUrl"))
            tokenUrl = ele.getAttribute("tokenUrl");

        if(ele.hasAttribute("accessTokenUrl"))
            accessTokenUrl = ele.getAttribute("accessTokenUrl");

        if(ele.hasAttribute("jsApiTicketUrl"))
            jsApiTicketUrl = ele.getAttribute("jsApiTicketUrl");
    }
}
